package com.dz51.core.utils;

import java.io.InputStream;
import java.util.Properties;

/**
 * @Title: PropertiesConfig.java
 * @Package com.dz51.core.utils
 * @Description: 读取Properties文件
 * @author Zhaoqt  
 * @date 2014-5-10 上午6:01:10
 * @version V1.0
 */
public class PropertiesConfig {
	
	private static Properties properties;
	/**
	 * 获取Properties
	 * @Title: getProperties
	 * @return
	 */
	public static Properties getProperties() {
		// 生成输入流  
		InputStream ins = Thread.currentThread().getContextClassLoader ().getResourceAsStream("application.properties");
		// 生成properties对象  
        properties = new Properties();  
        try {  
        	properties.load(ins);  
        } catch (Exception e) {  
            e.printStackTrace();  
        } finally {
        	try {
				if(ins != null) {
					ins.close();
					ins = null;
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
        }
        return properties;
	}
	
	public static String  getProperty(String key) {
		if( properties == null) {
			properties = getProperties();
		}
		return properties.getProperty(key);
	}
}
